<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<script type="text/javascript" src='resources/js/global/global.ca.js'></script>
<script type="text/javascript" src='resources/js/popup.js'></script>
<script type="text/javascript" src="resources/js/jquerylib/jquery.ui.core.js"></script>
<script type="text/javascript" src="resources/js/jquerylib/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="resources/js/jquerylib/jquery.ui.datepicker-zh-CN.js"></script>


<link rel='stylesheet' href='resources/css/jquerylib/jquery-ui-1.7.custom.css'/>
<script>
	
	$(function(){
		$(".time").datepicker({showOn: "both", buttonImage: "resources/images/jquerylib/cal.gif",  buttonImageOnly: true, dateFormat: 'yy-mm-dd', duration: 'normal'});

		$("#box-search-tabs li").click(function(){
			$("#box-search-tabs li").removeClass("current").removeClass("active");
			if (!$(this).hasClass("active")) {
				$(this).addClass("active");
			}
			$(this).addClass("current");
			if ($(this).attr("id")) {
				$("#box-search-forms form").css("display", "none");
				$("#frm_" + $(this).attr("id")).css("display", "block");
			}
		});
		
		KX.sugg_init_skb_fr(10, "highlightg", "highlighth", "lh", "t_from", "container1", 1, "frm_cxzz");
		KX.sugg_init_skb_fr(10, "highlightg", "highlighth", "lh", "t_to", "container2", 1, "frm_cxzz");
		KX.sugg_init_skb_fr(10, "highlightg", "highlighth", "lh", "t_stationname", "container3", 1, "frm_cxcz");
		
		$.each($("#box-search-tabs li"), function(){
			$(this).click(function(){
				var frm_id = $(this).attr("id");
				if ($("#frm_" + frm_id).find("div[id^=container]").size() > 0) {
					$.each($("#frm_" + frm_id).find("div[id^=container]"), function(){
						if (!$(this).attr("stat") && $(this).attr("stat") != "adjusted") {
							// style adjusted against container
							if ($("#" + $(this).attr("alt")).size() > 0) {
								var left_h = $("#" + $(this).attr("alt")).offset().left;
								var left_p = $("#frm_" + frm_id).offset().left;
								if ($("#frm_" + frm_id).css("margin-left")) {
									left_h += parseInt($("#frm_" + frm_id).css("margin-left"));
								}
								$(this).css("left", (left_h - left_p) + "px").attr("stat", "adjusted");
							}
						}
					});
				}
			});
		});	
		
		
		$(".view").click(function(){
			var id=$(this).parent().parent().attr("id");
			ShowIframe("123","http://localhost:8080/eduapp/admin/order/detail?id="+id,800,500);
		});
		
		$(".pass").click(function(){
			var id=$(this).parent().parent().attr("id");
			$.ajax({
					type: "POST",
					url: "admin/order/check",
					data: {"id":id,"status":1},
					success: function(data){
								$(this).val()="已审核";
								
						   }
						 });
		});
		
		
		$(".nopass").click(function(){
			var id=$(this).parent().parent().attr("id");
			$.ajax({
					type: "POST",
					url: "admin/order/check",
					data: {"id":id,"status":2},
					success: function(data){
								$(".pass").parent().parent().fade();
								$.blockUI({ 
						            message:  "成功!", 
						            fadeIn: 700, 
						            fadeOut: 700, 
						            timeout: 2000, 
						            showOverlay: false, 
						            centerY: false, 
						            css: { 
						                width: '300px', 
						                top: '80px', 
						                left: ($(window).width()-300)/2 + 'px', 
						                padding: '10px 0px 0px 0px', 
						                height:'30px',
						                backgroundColor: '#fff',
						                '-webkit-border-radius': '10px', 
						                '-moz-border-radius': '10px', 
						                color: '#000' 
						            } 
						        });
						   }
						 });
		});
	});

</script>


<div id="panel-left" style="margin-top:10px;margin-bottom:10px;"  >
	<div id="box-news" >
			<table cellspacing="0" cellpadding="0" width="98%">
				<tr>
					<td colspan="3">
						<table cellspacing="0" cellpadding="0" width="100%">
							<tr>
								<td class="title_banner_left"></td>
								<td class="title_banner_center"><span class="banner_header">订单管理</span></td>
								<td class="title_banner_right"></td>
							</tr>
						</table>
					</td>
				</tr>
                <tr>
                <td class="box_left"></td>
                <td>
                	 <div class="box" style="margin-top:10px;">
				<table cellspacing="0" cellpadding="0" border="0" width="90%" align="center">
                    <col width="6px" />
                    <col width="946px" />
                    <col width="6px" />
						<tr>
                            <td class="box_top_l"></td>
                            <td class="box_top_c box_title">查询条件</td>
                            <td class="box_top_r"></td>
						</tr>
                        <tr >
                        	<td class="box_left"></td>
                            <td>
                            <form action="admin/order/search/1" method="post" id="frm_cxzz" >
                            	<div class="p" align="center" style="margin-top:10px;">
					
						<div class="p">
                         <table width="80%" cellpadding="0" cellspacing="0" border="0" style="text-align:center;" class="datagrid" height="100">
                         	<tr align="left" >
                            	<td><span><td>用户名:</td><td><input type="text" size="18" name="accountRealName" class="text" value="${accountRealName}" id="accountRealName" /></td></span></td>
							<td><span><td>学号:</td> <td><input type="text" size="18" name="accountNo" class="text" value="${accountNo}" id="accountNo" /></td></span></td>
                            <td><span><td>专业:</td> <td><input type="text" size="18" name="accountMajority" class="text" value="${accountMajority}" id="accountMajority" /></td></span></td>
                            </tr>
							<tr align="left"> 
                            <td><span><td>班级:</td><td> <input type="text" size="18" name="accountClass" class="text" value="${accountClass}" id="accountClass" /></td></span></td>
                            <td><span><td>订单号:</td><td> <input type="text" size="18" name="orderNo" class="text" value="${orderNo}" id="orderNo" /></td></span></td>
                            <td><span><td>订单类型：</td> <td><select name="orderType" size=1>
                            			 <c:if test="${orderType!=null&&orderType!=0}">
                                            <c:if test="${orderType==1}">
                                            <option value="1">学生票</option>
                                       	 	</c:if>
                                            <c:if test="${orderType==2}">
                                            <option value="2">非学生票</option>
                                            </c:if>
                                         </c:if>
                            				<option value="0">请选择</option>
                                            <option value="1">学生票</option>
                                            <option value="2">非学生票</option>
                                            </select></td>
							</span></td>
                            </tr>
                            <tr align="left">
                            <td><span><td>订单状态：</td> <td><select name="orderStatus" size=1>
                            			 <c:if test="${orderStatus!=null&&orderStatus!=-1}">
                                            <c:if test="${orderStatus==0}">
                                        	 <option value="0">未审核</option>
                                       	 	</c:if>
                                            <c:if test="${orderStatus==1}">
                                             <option value="1">已通过</option>
                                            </c:if>
                                            <c:if test="${orderStatus==2}">
                                             <option value="2">未通过</option>
                                            </c:if>
                                            <c:if test="${orderStatus==3}">
                                             <option value="3">订票成功</option>
                                            </c:if>
                                            <c:if test="${orderStatus==4}">
                                             <option value="4">订票失败</option>
                                            </c:if>
                                         </c:if>
                           					<option value="-1">请选择</option>
                                            <option value="0">未审核</option>
                                            <option value="1">已通过</option>
                                            <option value="2">未通过</option>
                                            <option value="3">订票成功</option>
                                            <option value="4">订票失败</option>
                                            </select></td>
							</span>
                            <td>
                            <span>
                            <td>
                            	起始时间
                            </td>
                            <td>
                            	<input type="text" size="18" class="text time"  name="orderCreateTime" value="${orderCreateTime}"/>
                            </td>
                            </span>
                            </td>
                            <td>
                            <span>
                            <td>
                            	结束时间
                            </td>
                            <td>
                                <input type="text" size="18" class="text time"  name="orderEndTime" value="${orderEndTime}"/>
                            </td>
                            </span>
                            </td>
                           
                           </td>
                            </tr>
                            <tr>
                            <td>
                           	<td><input type="submit" value="查询" class="sbtn" /></td>
                            </td>
                            </tr>
                            </table>
						</div>
                        </form>
                                    
                            
                            
                              </td>
                <td class="box_right"></td>
                        </tr>
                        <tr>
                            <td class="box_btm_l"></td>
                            <td class="box_btm_c"></td>
                            <td class="box_btm_r"></td>
						</tr>
           		</table>
            </div>
                            
                
                <div class="box" style="margin-top:10px;">
				<table cellspacing="0" cellpadding="0" border="0" width="90%" align="center">
                    <col width="6px" />
                    <col width="946px" />
                    <col width="6px" />
						<tr>
                            <td class="box_top_l"></td>
                            <td class="box_top_c box_title">查询结果</td>
                            <td class="box_top_r"></td>
						</tr>
                        <tr >
                        	<td class="box_left"></td>
                            <td>
                            	 <!--结果-->
                    <div style="margin-top:10px;" align="center">
              			   <table width="95%" cellpadding="0" cellspacing="0" border="1" style="text-align:center;" class="datagrid">
                             <thead>
                               <tr >
                                 <c:if test="${idx % 2 == 1}">bgcolor="#fafbf5"</c:if>
                                 <td><input type="checkbox" id='ckall' /></td>
                                 <td>订单号</td>
                                 <td>订票人</td>
                                 <td>订票日期</td>
                                 <td>订单状态</td>
                                 <td>操作</td>
                               </tr>
                             </thead>
                             <logic:present name="result.page">
                               <logic:iterate name="result.page" property="items" id="entity">
                                 <tr id="${entity.id}">
                                   <td><input type="checkbox" id='ckall' /></td>
                                   <td>${entity.orderNo}</td>
                                   <td>${entity.orderOwner.accountRealName}</td>
                                   <td>${entity.orderCreateTime}</td>
                                   <td>
                                   		<c:if test="${entity.orderStatus==0}">
                                        <c:out value="未审核"/>
                                        </c:if>
                                        <c:if test="${entity.orderStatus==1}">
                                        <c:out value="已通过"/>
                                        </c:if>
                                        <c:if test="${entity.orderStatus==2}">
                                        <c:out value="未通过"/>
                                        </c:if>
                                   		<c:if test="${entity.orderStatus==3}">
                                        <c:out value="订票成功"/>
                                        </c:if>
                                        <c:if test="${entity.orderStatus==4}">
                                        <c:out value="订票失败"/>
                                        </c:if>
                                   </td>
                                   <td width="40%">
                                   	<input type="button" id="view" value="查看" class="sbtn view"  />
                                    <input type="button" value="通过" id="pass" class="sbtn pass"  />
                                    <input type="button" value="不通过" id="nopass" class="sbtn nopass" />	
                                   </td>
                                 </tr>
                               </logic:iterate>
                             </logic:present>
                             <tbody>
                             </tbody>
                           </table>

                            <!-- Pagination Support-->
                                    <div class="tablenav-pages" align="right">
                                        <logic:notEmpty name="result.page">
                                            <span class="displaying-num">
                                                显示 
                                                <bean:write name="result.page" property="currentPageStartIndex" />
                                                –
                                                <bean:write name="result.page" property="currentPageEndIndex" /> 
                                                共 
                                                <bean:write name="result.page" property="totalCount" />
                                            </span>
                                            <bean:define id="currentPage" name="result.page" property="currentPage" />
                                            <logic:iterate id="pageIndex" name="result.page" property="pages">
                                                <c:choose>
                                                    <c:when test="${pageIndex eq currentPage}">
                                                        <span id="currentPage" class="page-numbers current"><c:out value="${pageIndex}" /></span>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <a href="admin/order/page/<c:out value='${pageIndex}' />" class="page-numbers">
                                                            <c:out value="${pageIndex}" />
                                                        </a>
                                                    </c:otherwise>
                                                </c:choose>
                                            </logic:iterate>
                                        </logic:notEmpty>
                                    </div>      
              			
                                         
           			 </div> 
                     <!--End结果-->  
                            
                            
                              </td>
                <td class="box_right"></td>
                        </tr>
                        <tr>
                            <td class="box_btm_l"></td>
                            <td class="box_btm_c"></td>
                            <td class="box_btm_r"></td>
						</tr>
           		</table>
            </div>
                
                
                
                </td>
                <td class="box_right"></td>
                        </tr>
                        <tr>
                            <td class="box_btm_l"></td>
                            <td class="box_btm_c"></td>
                            <td class="box_btm_r"></td>
						</tr>
           		</table>
            </div>
       </div>
